package com.ns.school.common.exception;

import org.slf4j.Logger;

public class MyException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    public MyException(Exception msg) {
        super(msg);
    }

    public MyException(String msg) {
        super(msg);
    }

    /**
     * 打印异常信息到日志文件
     *
     * @param log
     * @param e   void
     */
    public static void print(Logger log, Exception e) {
        if (e.getMessage() != null && e.getMessage().contains("Broken pipe")) {
            printMessage(log, e);
        } else {
            log.error("Error: ", e);
        }
    }

    /**
     * 打印异常信息到日志文件
     *
     * @param log
     * @param e   void
     */
    public static void printMessage(Logger log, Exception e) {
        log.error("Error: {}", e.getMessage());
    }

}
